package com.zian.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum PayStatusEnum {

    UNPAID(0, "未支付"),
    SUCCESS(1, "支付成功"),
    FAILURE(-1, "支付失败");

    @JsonValue
    @EnumValue
    private final int code;
    private final String description;

    PayStatusEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }


    // 根据code值获取对应的枚举项
    public static PayStatusEnum getByCode(int code) {
        for (PayStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("No matching constant for [" + code + "]");
    }

}
